package com.example.marketapp.banco;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class BaseClienteDAO extends SQLiteOpenHelper {
	
	public static final String TABLE_CLIENTE 	= "cliente";
	public static final String CLIENTE_ID 		= "id_cliente";
	public static final String CLIENTE_NOME		= "nome";
	public static final String CLIENTE_CPF 		= "cpf";
	public static final String CLIENTE_EMAIL 	= "email";
	public static final String CLIENTE_SENHA 	= "senha";
	
	public static final String DATABASE_NAME 	= "cliente.db";
	public static final int DATABASE_VERSION 	= 1;
	
	public static final String CREATE_CLIENTE 	= "create table " + TABLE_CLIENTE + " ( " +
								CLIENTE_ID		+ " integer primary key autoincrement, " +
								CLIENTE_NOME	+ " text not null, " +
								CLIENTE_CPF		+ " text not null, " +
								CLIENTE_EMAIL	+ " text not null, " +
								CLIENTE_SENHA	+ " text not null);";

	public BaseClienteDAO(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		System.out.println("passou no " + this.toString());
		database.execSQL(CREATE_CLIENTE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
		database.execSQL("DROP TABLE IF EXISTS " + TABLE_CLIENTE);
		onCreate(database);
	}

}
